package com.qf.bank.userinfoprovider.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.bank.userinfoapi.po.UserInfo;
import com.qf.bank.userinfoapi.vo.UserInfoVo;
import com.qf.bank.userinfoprovider.mapper.UserInfoMapper;
import com.qf.bank.userinfoprovider.service.IUserInfoService;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author q
 * @since 2019-12-06
 */
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements IUserInfoService {
    @Override
    public Page<UserInfo> pageWithCondition(UserInfoVo userInfoVo) {
        QueryWrapper<UserInfo> wrapper = new QueryWrapper<>();
        if (userInfoVo != null) {
            if (userInfoVo.getId() != 0) {
                wrapper.lambda().like(UserInfo::getUserId, userInfoVo.getId());
            }
            if (userInfoVo.getCardNumber() != null) {
                wrapper.lambda().like(UserInfo::getCardNumber, userInfoVo.getCardNumber());
            }
            if (userInfoVo.getUserId()!= 0) {
                wrapper.lambda().lt(UserInfo::getUserId, userInfoVo.getUserId());
            }
            if (userInfoVo.getMode() != null) {
                wrapper.lambda().gt(UserInfo::getMode, userInfoVo.getMode());
            }
        }
        return (Page<UserInfo>)baseMapper.selectPage(new Page<>(userInfoVo.getCurrent(),userInfoVo.getSize()),wrapper);
    }
}
